package cn.tedu.review;

import java.math.BigDecimal;
import java.util.Scanner;

/**本类用于复习浮点数运算不精确的解决方案*/
public class TestBigDecimal {
    public static void main(String[] args) {
        System.out.println("请输入要计算的第1个数：");
        double a = new Scanner(System.in).nextDouble();

        System.out.println("请输入要计算的第2个数：");
        double b = new Scanner(System.in).nextDouble();

        BigDecimal bd1 = new BigDecimal(a+"");
        BigDecimal bd2 = new BigDecimal(b+"");

        System.out.println("加法“"+bd1.add(bd2));
        System.out.println("减法："+bd1.subtract(bd2));
        System.out.println("乘法："+bd1.multiply(bd2));
        System.out.println("除法："+bd1.divide(bd2,3,4));

    }
}
